package com.huhu.controller;


import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.huhu.pojo.Article;
import com.huhu.response.Response;
import com.huhu.service.IArticleService;


/**
 * 
 * @author 石虎虎
 *
 */

@Controller
@RequestMapping("/backend/")
public class BackendController {
	
	@Autowired
	private IArticleService iArticleService;
	
	/**
	 * 根据主键date进行delete
	 * @param date
	 * @return
	 */
	@RequestMapping(value="delete.do",method=RequestMethod.POST)
	@ResponseBody
	public Response<Article> delete(@Param("token")String token,@Param("date")Integer date) 
	{
			Response<Article> response=iArticleService.deleteArticle(date);
			return response;
		
	}
	
	/**
	 * 更新文章
	 * @param article
	 * @return
	 */
	@RequestMapping(value="update.do",method=RequestMethod.PUT)
	@ResponseBody
	public Response<Article> update(@Param("token")String token,@Param("article")Article article) 
	{
		Response<Article> response=iArticleService.updateArticle(article);
		return response;
		
	}
	
	/**
	 * 插入文章
	 * @param article
	 * @return
	 */
	@RequestMapping(value="insert.do",method=RequestMethod.POST)
	@ResponseBody
	public Response<Article> insert(@Param("token")String token,@Param("article")Article article) 
	{
		Response<Article> response=iArticleService.insertArticle(article);
		return response;
		
	}
	


}
